package io.wdb.wxapp.model;

import java.io.Serializable;
import java.util.Date;
import java.util.ArrayList;
import java.util.List;

import io.swagger.annotations.ApiModelProperty;

import io.wdb.modules.activity.wxapp.entity.HdActivityEntity;


/**
 * 活动配置
 * 
 * @author wdb
 * @email xulin@wdb007.com
 * @date 2018-01-20 15:11:02
 */
public class HdActivityModel implements Serializable {
	private static final long serialVersionUID = 1L;
	
	private String activityId;

	@ApiModelProperty(value = "", required = true)
	private String name;
	@ApiModelProperty(value = "1-抢卡活动，前缀 card_2-伴读活动，前缀 read_", required = true)
	private Integer type;
	@ApiModelProperty(value = "活动开始时间", required = true)
	private Date startTime;
	@ApiModelProperty(value = "活动结束时间", required = true)
	private Date endTime;
	@ApiModelProperty(value = "1- available, 0-unavailable", required = true)
	private Integer available;
	@ApiModelProperty(value = "0-不限制", required = true)
	private Integer initiateLimit;
	@ApiModelProperty(value = "0-不限制", required = true)
	private Integer attendLimit;
	
	private String imgUrl;
	private String jumpUrl;
	private String content;
	
	public String getImgUrl() {
		return imgUrl;
	}
	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	}
	public String getJumpUrl() {
		return jumpUrl;
	}
	public void setJumpUrl(String jumpUrl) {
		this.jumpUrl = jumpUrl;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getActivityId() {
		return activityId;
	}
	public void setActivityId(String activityId) {
		this.activityId = activityId;
	}
	/**
	 * 设置：
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * 获取：
	 */
	public String getName() {
		return name;
	}
	/**
	 * 设置：1-抢卡活动，前缀 card_
2-伴读活动，前缀 read_
	 */
	public void setType(Integer type) {
		this.type = type;
	}
	/**
	 * 获取：1-抢卡活动，前缀 card_
2-伴读活动，前缀 read_
	 */
	public Integer getType() {
		return type;
	}
	/**
	 * 设置：活动开始时间
	 */
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	/**
	 * 获取：活动开始时间
	 */
	public Date getStartTime() {
		return startTime;
	}
	/**
	 * 设置：活动结束时间
	 */
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	/**
	 * 获取：活动结束时间
	 */
	public Date getEndTime() {
		return endTime;
	}
	/**
	 * 设置：1- available, 0-unavailable
	 */
	public void setAvailable(Integer available) {
		this.available = available;
	}
	/**
	 * 获取：1- available, 0-unavailable
	 */
	public Integer getAvailable() {
		return available;
	}
	/**
	 * 设置：0-不限制
	 */
	public void setInitiateLimit(Integer initiateLimit) {
		this.initiateLimit = initiateLimit;
	}
	/**
	 * 获取：0-不限制
	 */
	public Integer getInitiateLimit() {
		return initiateLimit;
	}
	/**
	 * 设置：0-不限制
	 */
	public void setAttendLimit(Integer attendLimit) {
		this.attendLimit = attendLimit;
	}
	/**
	 * 获取：0-不限制
	 */
	public Integer getAttendLimit() {
		return attendLimit;
	}

    public static HdActivityModel convert(HdActivityEntity entity) {
		if(entity == null) {
			return null;
		}
		HdActivityModel model = new HdActivityModel();
		
				model.setActivityId(entity.getId());
				model.setName(entity.getName());
				model.setType(entity.getType());
				model.setStartTime(entity.getStartTime());
				model.setEndTime(entity.getEndTime());
				model.setAvailable(entity.getAvailable());
				model.setInitiateLimit(entity.getInitiateLimit());
				model.setAttendLimit(entity.getAttendLimit());
				model.setJumpUrl(entity.getJumpUrl());
				model.setImgUrl(entity.getImgUrl());
				model.setContent(entity.getContent());
				
		return model;
	}
	public static List<HdActivityModel> convert(List<HdActivityEntity> entities){
		if(entities == null || entities.isEmpty()) {
			return null;
		}
		List<HdActivityModel> models = new ArrayList<>();
		
		for(HdActivityEntity entity:entities) {
			models.add(convert(entity));
		}
		
		return models;
	}
	
	public static HdActivityEntity convert(HdActivityModel model) {
		if(model == null) {
			return null;
		}
		HdActivityEntity entity = new HdActivityEntity();
				entity.setName(model.getName());
				entity.setType(model.getType());
				entity.setStartTime(model.getStartTime());
				entity.setEndTime(model.getEndTime());
				entity.setAvailable(model.getAvailable());
				entity.setInitiateLimit(model.getInitiateLimit());
				entity.setAttendLimit(model.getAttendLimit());
				entity.setJumpUrl(model.getJumpUrl());
				entity.setContent(entity.getContent());
				entity.setImgUrl(model.getImgUrl());
				
		return entity;
	}

}
